import 'package:equatable/equatable.dart';

class ApiTimeDto extends Equatable {
  const ApiTimeDto._internal({
    required this.timeString,
  });

  final String timeString;

  @override
  List<Object?> get props {
    return [
      timeString,
    ];
  }

  factory ApiTimeDto.fromString(String timeString) {
    return ApiTimeDto._internal(
      timeString: timeString,
    );
  }

  factory ApiTimeDto.fromEntity(DateTime time) {
    return ApiTimeDto._internal(
      timeString: time.toIso8601String(),
    );
  }

  @override
  String toString() {
    return timeString;
  }

  DateTime toEntity() {
    return DateTime.parse(timeString);
  }
}
